Page({
  data: {
    bgd29: "",
    bgd30: "",
    bgd31: "",
    bgd32: "",
    bgd33: "",
    bgd34: "",
    bgd35: "",
    bgd36: "",
    bgd37: "",
    bgd38: "",
    bgd39: "",
    bgd40: "",
    bgd41: "",
    bgd42: "",
    bgd43: "",
    bgd44: "",
    bgd45: "",
    bgd46: "",
    bgd47: "",
    bgd48: "",
    bgd49: "",
    bgd50: "",
    bgd51: "",
    bgd52: "",
    bgd53: "",
    bgd54: "",
    bgd55: "",
    bgd56: "",
  },
  onLoad: function () {
    console.log("order进来");
    //wx.clearStorage();
    var that = this;   
    wx.request({
      url: 'https://www.szz5.com/admin/selectAll',
      method: 'POST',
      data: {},
      success: function (res) {
        console.info("++++++++++=1", JSON.stringify(res));
        var list = res.data;
        console.info("++++++++++=2", JSON.stringify(list));
        if (list != null) {
          for (var index in list) {
            console.info("++++++++++=3", list[index]);
            var bathid = list[index];
            if (bathid == '029') {
              console.info("进来001");
              that.setData({
                bgd29: "red"
              });
            }
            if (bathid == "030") {
              console.info("进来002");
              that.setData({
                bgd30: "red"
              });
            }
            if (bathid == "031") {
              that.setData({
                bgd31: "red"
              });
            }
            if (bathid == "032") {
              that.setData({
                bgd32: "red"
              });
            }
            if (bathid == "033") {
              that.setData({
                bgd33: "red"
              });
            }
            if (bathid == "034") {
              that.setData({
                bgd34: "red"
              });
            }
            if (bathid == "035") {
              that.setData({
                bgd35: "red"
              });
            }
            if (bathid == "036") {
              that.setData({
                bgd36: "red"
              });
            }
            if (bathid == "037") {
              that.setData({
                bgd37: "red"
              });
            }
            if (bathid == "038") {
              that.setData({
                bgd38: "red"
              });
            }
            if (bathid == "039") {
              that.setData({
                bgd39: "red"
              });
            }
            if (bathid == "040") {
              that.setData({
                bgd40: "red"
              });
            }
            if (bathid == "041") {
              that.setData({
                bgd41: "red"
              });
            }
            if (bathid == "042") {
              that.setData({
                bgd42: "red"
              });
            }
            if (bathid == "043") {
              that.setData({
                bgd43: "red"
              });
            }
            if (bathid == "044") {
              that.setData({
                bgd16: "red"
              });
            }
            if (bathid == "045") {
              that.setData({
                bgd17: "red"
              });
            }
            if (bathid == "046") {
              that.setData({
                bg46: "red"
              });
            }
            if (bathid == "047") {
              that.setData({
                bgd47: "red"
              });
            }
            if (bathid == "048") {
              that.setData({
                bgd48: "red"
              });
            }
            if (bathid == "049") {
              that.setData({
                bgd49: "red"
              });
            }
            if (bathid == "050") {
              that.setData({
                bgd50: "red"
              });
            }
            if (bathid == "051") {
              that.setData({
                bgd51: "red"
              });
            }
            if (bathid == "052") {
              that.setData({
                bgd52: "red"
              });
            }
            if (bathid == "053") {
              that.setData({
                bgd53: "red"
              });
            }
            if (bathid == "054") {
              that.setData({
                bgd54: "red"
              });
            }
            if (bathid == "055") {
              that.setData({
                bgd55: "red"
              });
            }
            if (bathid == "056") {
              that.setData({
                bgd56: "red"
              });
            }
          }

          // wx.showToast({
          //   title: '获取数据失败',      
          //   duration: 1500      
          // })
        }
      }
    })
  },
  gotoresult: function (e) {
    var ID = e.currentTarget.id;
    console.log("idd", ID);
    // wx.clearStorage("userInfo");
    var stor = wx.getStorageSync("userInfo");
    var getkey = wx.getStorageSync("key1");
    if (stor == null || stor == "") {
      console.log("stor" + stor);
      wx.showModal({
        title: '提示',
        content: '您没有激活状态，请去激活',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定');

            wx.hideToast()
            wx.switchTab({
              url: '../../login/login'
            })

            console.log('1');
            // return;
          } else if (res.cancel) {
            console.log('用户点击取消');
            return;
          }
        }
      })
    } else if (getkey) {
      wx.showModal({
        title: '提示',
        content: '您已经选择过！',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定');
            return;
          } else if (res.cancel) {
            console.log('用户点击取消');
            return;
          }
        }
      })

    } else {

      wx.request({
        url: 'https://www.szz5.com/admin/byBathId',
        method: 'POST',
        data: { bathId: ID },
        success: function (res) {
          console.info("++++++++++=4", JSON.stringify(res));
          if (res.data == '1') {
            wx.showModal({
              title: '提示',
              content: '此澡位已被预订！',
              success: function (res) {
                if (res.confirm) {
                  console.log('用户点击确定');
                  return;
                } else if (res.cancel) {
                  console.log('用户点击取消');
                  return;
                }
              }
            })
          }
        }

      })
      wx.showModal({
        title: '提示',
        content: '是否预定该位置',
        success: function (res) {
          if (res.confirm) {
            console.log('用户点击确定');
            wx.setStorageSync("keykey", ID);
            wx.navigateTo({
              url: '../../seltime/seltime',
            })
            return;
          } else if (res.cancel) {
            console.log('用户点击取消');
            return;
          }
        }
      })

    }
    // wx.getStorage({
    //   key: 'key',
    //   success: function (res) {
    //     console.log(res.data);
    //     if(res){
    //       console.log(res);

    //       return;
    //     }
    //   },
    // });



  }



})